//
//  DetaiTextVC.m
//  YiXiu
//
//  Created by yixiu on 16/7/25.
//  Copyright © 2016年 zzz. All rights reserved.
//

#import "DetaiTextVC.h"
#import "DetailCell.h"

@interface DetaiTextVC ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView * tableView;



@end

@implementation DetaiTextVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.tableView];
}

//- (void)viewWillAppear:(BOOL)animated{
//    
//    [super viewWillAppear:animated];
//    
//    [self getDetailData];
//}



- (UITableView *)tableView{
    
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - 40) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.bounces = NO;
        
    }
    return _tableView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0) {
        return 1;
    }else{
        return 22;
    }
    
//        return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell * cell;
    if (indexPath.section == 0) {
        DetailCell *  Dcell = [[DetailCell alloc] init];
        Dcell.model = self.model;
        Dcell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        cell = Dcell;
        
    }else{
        
        cell = [[UITableViewCell alloc] init];
        cell.backgroundColor = [UIColor grayColor];
    }
    
    
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        return self.model.totalHeight;
    }else{
        
        return 60;
    }
    
}







- (void)getDetailData{
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    /*
     Dang	String	第几页
     */
    dic[@"p_id"] = self.p_id;
    
    [NetWorkingTool POST:@"selfPost/getSelfPostBySelfDetails" parameters:dic success:^(id responseObject, NSError *error) {
        NSLog(@"----selfPost/index---%@--%@",responseObject,error);
        
        NSDictionary * dic = [responseObject objectForKey:@"json1"];
//        NSArray * arr = [responseObject objectForKey:@"json2"];
        
        
        
//        CommModel * model = self.model.model;
        
        
        
        
//        ShaDetailSizeModel * modelSize = [[ShaDetailSizeModel alloc] init];
//        modelSize.model = model;
//        self.model = modelSize;
        
        
        [self.tableView reloadData];
        
    } failure:^(id responseObject, NSError *error) {
        NSLog(@"----selfPost/index--%@--%@",responseObject,error);
        
        [MBProgressHUD showError:[error description]];
    }];
    

    
}




@end
